﻿<navigation:Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Ria"
    xmlns:my="clr-namespace:AdminApp.Web.Services"
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:converter="clr-namespace:TheOliver.DigitalSignage.Common;assembly=TheOliver.DigitalSignage.Common" xmlns:AdminApp_Controls="clr-namespace:AdminApp.Controls"
    x:Class="AdminApp.Views.Speaker"
    d:DesignWidth="743.5"
    d:DesignHeight="541.5"
    Title="Speaker Page"
    >
    <navigation:Page.Resources>
        <converter:ImageConverter
            x:Key="_imageConverter" />
        <DataTemplate
            x:Key="SpeakerDataTemplate">
            <Grid Width="300" d:DesignHeight="139" Height="129">
                <Rectangle
                    Stroke="#FF999999"
                    RadiusY="15"
                    RadiusX="15" Margin="4">
                    <Rectangle.Fill>
                        <LinearGradientBrush
                            EndPoint="0.5,0"
                            StartPoint="0.5,1">
                            <GradientStop
                                Color="Black"
                                Offset="0.902" />
                            <GradientStop
                                Color="White"
                                Offset="1" />
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Grid
                    Margin="16"
                    d:LayoutOverrides="Width, Height"
                    >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition
                            Width="117" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Image
                        x:Name="_speakerImage"
                        Margin="8" 
                        Source="{Binding ImageData, Converter={StaticResource _imageConverter}}"/>
                    <StackPanel
                        Orientation="Vertical"
                        Grid.Column="1"
                        Margin="8">
                        <StackPanel
                            HorizontalAlignment="Left"
                            Orientation="Horizontal"
                            Margin="0,0,0,4">
                            <TextBlock
                                x:Name="_speakerFirstName"
                                Foreground="White"
                                TextWrapping="Wrap"
                                Text="{Binding Firstname}"
                                VerticalAlignment="Top"
                                d:LayoutOverrides="Width" />
                            <TextBlock
                                x:Name="_speakerLastName"
                                Foreground="White"
                                TextWrapping="Wrap"
                                Text="{Binding Lastname}"
                                VerticalAlignment="Top"
                                d:LayoutOverrides="Width"
                                Margin="4,0,0,0" />
                        </StackPanel>
                        <TextBlock
                            x:Name="_speakerTitle"
                            Foreground="White"
                            HorizontalAlignment="Left"
                            Margin="0,0,0,4"
                            TextWrapping="Wrap"
                            Text="{Binding Title}"
                            VerticalAlignment="Top"
                            d:LayoutOverrides="Width" />
                        <TextBlock
                            x:Name="_speakerBiography"
                            Foreground="White"
                            HorizontalAlignment="Left"
                            Margin="0,0,0,4"
                            TextWrapping="Wrap"
                            Text="{Binding Biography}"
                            VerticalAlignment="Top"
                            d:LayoutOverrides="Width" />
                    </StackPanel>
                </Grid>
            </Grid>
        </DataTemplate>
    </navigation:Page.Resources>
    <controlsToolkit:BusyIndicator
        IsBusy="{Binding DomainContext.IsLoading, ElementName=speakerDomainDataSource}">
        <Grid
            x:Name="LayoutRoot">
            <Grid.RowDefinitions>
                <RowDefinition Height="39" />
                <RowDefinition/>
                <RowDefinition
                    Height="41" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="350" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <riaControls:DomainDataSource
                AutoLoad="True"
                Height="0"
                LoadedData="speakerDomainDataSource_LoadedData"
                x:Name="speakerDomainDataSource"
                QueryName="GetSpeakerQuery"
                Width="0"
                Margin="167,12,167,29"
                Grid.Column="1"
                Grid.Row="2">
                <riaControls:DomainDataSource.DomainContext>
                    <my:DigitalSignageDomainContext />
                </riaControls:DomainDataSource.DomainContext>
            </riaControls:DomainDataSource>
            <Grid
                DataContext="{Binding SelectedItem, ElementName=_speakerList}"
                Margin="8"
                x:Name="_detailGrid"
                Grid.Column="1" Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition
                        Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition
                        Height="29" />
                    <RowDefinition
                        Height="29" />
                    <RowDefinition
                        Height="29" />
                    <RowDefinition />
                    <RowDefinition Height="137" />
                </Grid.RowDefinitions>

                <TextBlock
                    Grid.Column="0"
                    Grid.Row="0"
                    HorizontalAlignment="Left"
                    Margin="3,3,0,3"
                    Text="Firstname:"
                    VerticalAlignment="Center" />
                <TextBox
                    Grid.Column="1"
                    Grid.Row="0"
                    Height="23"
                    Margin="3"
                    x:Name="firstnameTextBox"
                    Text="{Binding Firstname, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                    VerticalAlignment="Center" />
                <TextBlock
                    Grid.Column="0"
                    Grid.Row="1"
                    HorizontalAlignment="Left"
                    Margin="3,3,0,3"
                    Text="Lastname:"
                    VerticalAlignment="Center" />
                <TextBox
                    Grid.Column="1"
                    Grid.Row="1"
                    Height="23"
                    Margin="3"
                    x:Name="lastnameTextBox"
                    Text="{Binding Lastname, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                    VerticalAlignment="Center" />
                <TextBlock
                    Grid.Column="0"
                    Grid.Row="2"
                    HorizontalAlignment="Left"
                    Margin="3,3,0,3"
                    Text="Title:"
                    VerticalAlignment="Center" />
                <TextBox
                    Grid.Column="1"
                    Grid.Row="2"
                    Height="23"
                    Margin="3"
                    x:Name="titleTextBox"
                    Text="{Binding Title, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                    VerticalAlignment="Center" />
                <TextBlock
                    Grid.Column="0"
                    Grid.Row="4"
                    HorizontalAlignment="Left"
                    Margin="3,7,0,0"
                    Text="Image:"
                    VerticalAlignment="Top" />
                <TextBlock
                    Grid.Column="0"
                    Grid.Row="3"
                    HorizontalAlignment="Left"
                    Margin="1,8,0,0"
                    Text="Biography:"
                    VerticalAlignment="Top" />
                <TextBox
                    Grid.Row="3"
                    Margin="3,4,3,8"
                    x:Name="biographyTextBox"
                    Text="{Binding Biography, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                    TextWrapping="Wrap" Grid.ColumnSpan="1" Grid.Column="1" VerticalScrollBarVisibility="Auto" AcceptsReturn="True" />
                <StackPanel Grid.Column="1" Margin="-1,8,8,8" Orientation="Horizontal" Grid.Row="4" d:LayoutOverrides="Width">
                	<Image
                		x:Name="_speakerImage"
                		Source="{Binding ImageData, Converter={StaticResource _imageConverter}}" />
                	<Button
                		x:Name="_selectSpeakerImage"
                		Content="..."
                		Width="22"
                		VerticalAlignment="Top"
                		Click="_selectSpeakerImage_Click" Margin="8,0,0,0" />
                </StackPanel>
            </Grid>
            <StackPanel
                Margin="0,0,209,8"
                x:Name="_speakerPanel"
                VerticalAlignment="Bottom"
                Orientation="Horizontal"
                Grid.Row="2"
                HorizontalAlignment="Right">
                <Button
                    Content="Add Speaker"
                    x:Name="_add"
                    Click="_add_Click"
                    Margin="4,0" />
                <Button
                    Content="Remove Speaker"
                    x:Name="_delete"
                    Click="_delete_Click"
                    Margin="4,0" />
            </StackPanel>
            <StackPanel
                x:Name="_changesPanel"
                Margin="0,0,8,8"
                Orientation="Horizontal"
                VerticalAlignment="Bottom"
                Grid.Column="1"
                HorizontalAlignment="Right"
                Grid.Row="2"/>
            <ListBox
                x:Name="_speakerList"
                Margin="8"
                Grid.RowSpan="1"
                ItemsSource="{Binding Data, ElementName=speakerDomainDataSource}"
                ItemTemplate="{StaticResource SpeakerDataTemplate}" Grid.Row="1" />

        	<AdminApp_Controls:SaveAndRejectControl
        		Grid.Column="1"
        		Margin="0"
        		Grid.Row="2"
        		DataContext="{Binding ElementName=speakerDomainDataSource}" HorizontalAlignment="Right" VerticalAlignment="Bottom" />
        	<AdminApp_Controls:SearchControl Margin="8"
                SearchTextChanged="SearchControl_SearchTextChanged" />

        </Grid>
    </controlsToolkit:BusyIndicator>
</navigation:Page>
